home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Files / FileAccessPath.h < prev    next >
Text File  |  1997-06-28  |  1KB  |  69 lines

  1. // FileAccessPath.h
  2.  
  3. #ifndef FileAccessPath_h
  4. #define FileAccessPath_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9. #ifndef FilePermission_h
  10. #include "FilePermission.h"
  11. #endif
  12. #ifndef Assert_h
  13. #include "Assert.h"
  14. #endif
  15.  
  16. class FileLocation;
  17.  
  18. class FileAccessPath
  19.   {
  20.     private:
  21.         int16 refNum;
  22.         bool isOpen;
  23.         
  24.         // intentionally undefined:
  25.             FileAccessPath( const FileAccessPath& );
  26.             void operator=( const FileAccessPath& );
  27.         
  28.         static void ThrowError( OSErr );
  29.         
  30.     public:
  31.         enum DataFork        { dataFork };
  32.         enum ResourceFork { resourceFork };
  33.         
  34.         FileAccessPath();
  35.         FileAccessPath( const FileLocation&,
  36.                              FilePermission,
  37.                              DataFork = dataFork );
  38.  
  39.         FileAccessPath( const FileLocation&,
  40.                              FilePermission,
  41.                              ResourceFork );
  42.         
  43.         ~FileAccessPath();
  44.         
  45.         bool IsOpen() const                        { return isOpen; }
  46.         
  47.         void Open( const FileLocation&,
  48.                       FilePermission,
  49.                       DataFork = dataFork );
  50.         
  51.         void Open( const FileLocation&,
  52.                       FilePermission,
  53.                       ResourceFork );
  54.                       
  55.         void Close();
  56.         
  57.         int16 RefNum() const                        { Assert( isOpen ); return refNum; }
  58.         
  59.         uint32 Length() const;
  60.         void SetLength( uint32 );
  61.         
  62.         uint32 Allocate( uint32 );                    // returns amount actually allocated;
  63.         uint32 AllocateContiguous( uint32 );    // throws disk full on failure.
  64.         
  65.         void Flush() const;
  66.   };
  67.  
  68. #endif
  69.